import React from 'react';
import moment from 'moment';
import { Input, Button, Select, Upload, Form, Cascader, DatePicker, Row, Col,Card,Modal,Icon,Menu,Table,Collapse,Radio,AutoComplete,InputNumber,message  } from 'antd';
import ajax from '../../common/ajax';
import {browserHistory} from 'react-router';
import config from '../../config/config';
const allRouter=config.router;
const FormItem = Form.Item;
const Option = Select.Option;
const Search = Input.Search;
const Panel = Collapse.Panel;
const { TextArea } = Input;
//药方模拟数据
const data=[
    {index:1,name:'金银花',dose:12,spec:'g',explanation:'后下，炖煮',},
    {index:2,name:'枸杞',dose:12,spec:'g',explanation:'后下，炖煮',}
]
class GetMedicine1 extends React.Component {
    constructor(props){
        super(props);
        this.state = {
            isChineseMedicine:1,//中药处方和西药处方切换,
            allMedicineData:data,
            visible: false
        }

    }
    componentWillMount() {}
    componentDidMount() {}
    changeTab1(key) {
        this.setState({ isChineseMedicine: key })
    }
    //显示模态框，完成就诊
    showModal () {
        this.setState({
            visible: true,
        });
    }
    handleOk (e) {
        console.log(e);
        this.setState({
            visible: false,
        });
    }
    handleCancel(e) {
        console.log(e);
        this.setState({
            visible: false,
        });
    }
    //点击确认取药提示
    getMedicineConfirm(){
        Modal.confirm({
            title: '确定取药',
            content: '确定之后将完成，是否确定取药?',
            cancelText:'取消',
            okText:'确定',
            onCancel: () => { message.info('取消取药') },
            onOk: () => {
                browserHistory.push('pharmacy');
                //发送Ajax请求
                // let url=allRouter.patientOrigin+'/sheduling/delete';
                // ajax('post',url,)
                //     .then(data=>{
                //         console.log(data);
                //         if(data.code==200){
                //             message.success('删除成功！', 2);
                //             this.getScheduleList();
                //         }else{
                //             message.info('删除失败');
                //         }
                //     })
                //     .catch(err=>{
                //         console.log(err);
                //     });
            }
        })
    }
    render(){
        //处方的表格
        const columns = [
            {
                title: '药品名称',
                dataIndex: 'name',
                width: 200,
            },{
                title: '剂量（次）',
                dataIndex: 'dose',
                width: 200,
            },{
                title: '规格',
                dataIndex: 'spec',
                width: 100,
            },{
                title: '说明',
                dataIndex: 'explanation',
                width: 200,
            }
        ];
        const text =
            <ul>
                <li><span>发病日期：</span><p>2017-12-02 00:00</p></li>
                <li><span>主诉：</span><p>主诉内容。咽痛、发热1天</p></li>
                <li><span>现病史：</span><p>现病史内容。1天前受凉后咽口水疼痛，发热，未测体温，伴肌肉酸痛，浑身乏力，无畏冷、寒战，无咳嗽、咳痰，夜眠尚可。</p></li>
                <li><span>既往史：</span><p>既往病史内容。服“阿莫西林胶囊”出现皮疹，有/否认高血压、糖尿病史。</p></li>
                <li><span>过敏史：</span><p>阿司匹林，表现为局部皮肤红肿、痒感，重度</p></li>
                <li><span>个人史：</span><p>个人史。吸烟2年，10支/日，已戒烟3个月。</p></li>
                <li><span>家族史：</span><p>家族史。无特殊。</p></li>
                <li><span>初步诊断：</span><p>病毒性感冒</p></li>
                <li><span>治疗意见：</span><p>1、适当休息，饮水，加强口腔卫生，可使用10%淡盐水漱口，每日三次；2、监测体温，体温大于39℃可使用布洛芬悬液10ml退热，退热出汗后注意补充水分；3、药物治疗：口服白加黑3日（白天服用白片 1片，晚上服用黑片 1片），阿奇霉素 500mg qd*3天：阿奇霉素可能出现恶心、腹胀、腹泻等副作用；4、随诊计划：三天后电话随诊，如有精神不振，高热及时就医。</p></li>
            </ul>
        return (
            <div className='container triage'>
                <div className='box'>
                    <div className='patientinfo'>
                        <img src=''/>
                        <h6>张胜男</h6>
                        <p>15888889874</p>
                        <div className='patientinfoa'>
                            <p>性别：女</p>
                            <p>年龄：26岁</p>
                            <p>婚配：未婚</p>
                            <p>身高：160CM</p>
                            <p>脉搏：110次/分钟</p>
                            <p>呼吸：68次/分钟</p>
                            <p>血压：90/110mmHg</p>
                            <p>过敏史：否认</p>
                        </div>
                    </div>
                    <div className='patientinfo1'>
                        <div className='addpatient'>
                            <div className='bxa'>
                                <div className='addpatient1'>
                                    <p>取药</p>
                                    <Button type="primary" style={{marginRight:'20px'}} onClick={this.showModal.bind(this)}>查看病例</Button>
                                    <Modal
                                        title="查看病例"
                                        visible={this.state.visible}
                                        onOk={this.handleOk.bind(this)}
                                        onCancel={this.handleCancel.bind(this)}
                                        className={"ckbl"}
                                    >
                                        <Collapse accordion>
                                            <Panel header={<div className="clearfix caozuo"><h4>妇科-初诊-2017-12-05-22：03-井湾子店</h4></div>} key="2">
                                                <div className="jzxx">{text}</div>
                                            </Panel>
                                            <Panel header="This is panel header 2" key="3">
                                                <div className="jzxx">{text}</div>
                                            </Panel>
                                            <Panel header="This is panel header 3" key="4">
                                                <div className="jzxx">{text}</div>
                                            </Panel>
                                        </Collapse>
                                    </Modal>
                                </div>
                                <div style={{paddingTop:'20px'}} className="treat-patient-content">
                                    <div className='btnBox'>
                                        <Row>
                                            <Col span={20} offset={1} >
                                                <Button type={this.state.isChineseMedicine == 1 ? 'primary':''} onClick={() => this.changeTab1(1)}>中药处方</Button>
                                                <Button  type={this.state.isChineseMedicine == 0 ? 'primary':''} onClick={() => this.changeTab1(0)} disabled>西药处方</Button>
                                            </Col>
                                        </Row>
                                        {this.state.isChineseMedicine == 1 ?
                                            <div>
                                                <Row style={{marginTop:'20px'}}>
                                                    <Col span={22} offset={1}>
                                                        <div className='bxa'>
                                                            <div className='addpatient1'>
                                                                <p>药方名称：小儿咳嗽药方</p>
                                                                <Button style={{marginRight:'20px'}} disabled>已付费</Button>
                                                            </div>
                                                            <div style={{paddingTop:'20px'}} className="treat-patient-content">
                                                                <Table
                                                                    rowKey="index"
                                                                    columns={columns}
                                                                    dataSource={this.state.allMedicineData}
                                                                    pagination={false}
                                                                    bordered
                                                                />
                                                            </div>
                                                            <Row style={{marginTop:'20px'}}>
                                                                <Col span={2} offset={16}>
                                                                    用法: <b>直接喝</b>
                                                                </Col>
                                                                <Col span={2}>
                                                                    频次: <b>每天3次</b>
                                                                </Col>
                                                                <Col span={2}>
                                                                    服用天数: <b>3天</b>
                                                                </Col>
                                                                <Col span={2}>
                                                                    取药方式: <b>代煎</b>
                                                                </Col>
                                                            </Row>
                                                            <Row style={{marginTop:'20px',marginBottom:'10px'}}>
                                                                <Col span={2} offset={20}>
                                                                    <Button type="primary" onClick={this.getMedicineConfirm.bind(this)}>确定取药</Button>
                                                                </Col>
                                                                <Col span={2}>
                                                                    <Button>打印</Button>
                                                                </Col>
                                                            </Row>
                                                        </div>
                                                    </Col>
                                                </Row>
                                                <Row style={{marginTop:'20px'}}>
                                                    <Col span={22} offset={1}>
                                                        <div className='bxa'>
                                                            <div className='addpatient1'>
                                                                <p>药方名称：小儿咳嗽药方</p>
                                                                <Button style={{marginRight:'20px',color:'red'}} disabled>未付费</Button>
                                                            </div>
                                                            <div style={{paddingTop:'20px'}} className="treat-patient-content">
                                                                <Table
                                                                    rowKey="index"
                                                                    columns={columns}
                                                                    dataSource={this.state.allMedicineData}
                                                                    pagination={false}
                                                                    bordered
                                                                />
                                                            </div>
                                                            <Row style={{marginTop:'20px'}}>
                                                                <Col span={2} offset={16}>
                                                                    用法: <b>直接喝</b>
                                                                </Col>
                                                                <Col span={2}>
                                                                    频次: <b>每天3次</b>
                                                                </Col>
                                                                <Col span={2}>
                                                                    服用天数: <b>3天</b>
                                                                </Col>
                                                                <Col span={2}>
                                                                    取药方式: <b>代煎</b>
                                                                </Col>
                                                            </Row>
                                                            <Row style={{marginTop:'20px',marginBottom:'10px'}}>
                                                                <Col span={2} offset={20}>
                                                                    <Button type="primary">确定取药</Button>
                                                                </Col>
                                                                <Col span={2}>
                                                                    <Button>打印</Button>
                                                                </Col>
                                                            </Row>
                                                        </div>
                                                    </Col>
                                                </Row>
                                            </div> : <div>
                                                <Row>
                                                    <Col span={2} offset={1}>西药处方</Col>
                                                </Row>
                                            </div>}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        );
    }
}
const GetMedicine = Form.create()(GetMedicine1);
export default GetMedicine;